/**
 * 鼠标的事件的文字提示
 */
class MouseHelper {
  helperTips:any
  constructor() {
    this.helperTips=null;
  }
  /**
   * 创建文字提示
   * @param screenPosition
   * @param text
   * @param offset { x,y}  因为map的页面并不一定是占满完整的页面的，可能是某个窗
   */
  createHelper(screenPosition: any, text: string,offset:any) {
    if(!offset){ offset={x:0,y:0} }
    this.helperTips = document.createElement('div');
    this.helperTips.innerText = text;
    this.helperTips.style.color = '#DC143C';
    this.helperTips.style.position = 'fixed';
    this.helperTips.style.fontSize='12px';
    this.helperTips.style.left = (screenPosition['x']+offset['x']+30) + 'px';
    this.helperTips.style.top = (screenPosition['y'] + offset['y'])+ 'px';
    this.helperTips.style.backgroundColor = '#FFFFFF';
    this.helperTips.style.padding = '2px';
    this.helperTips.style.borderRadius='2px';
    document.body.appendChild(this.helperTips);
  }

  /**
   * 更新文字提示
   * @param screenPosition
   * @param text
   * @param offset { x,y}  因为map的页面并不一定是占满完整的页面的，可能是某个窗
   */
  updateHelper(screenPosition: any, text: string,offset:any) {
    if(!offset){ offset={x:0,y:0} }
    this.helperTips.style.left = (screenPosition['x']+offset['x']+30) + 'px';
    this.helperTips.style.top = (screenPosition['y'] + offset['y'])+ 'px';
    this.helperTips.innerText = text;
  }

  removeHelper() {
    if(this.helperTips){
      this.helperTips.remove();
    }
  }

}
export default new MouseHelper();



